package cn.tedu.ivos2.user.controller;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import cn.tedu.ivos2.base.response.JsonResult;
import cn.tedu.ivos2.user.pojo.dto.UserLoginParam;
import cn.tedu.ivos2.user.pojo.vo.UserVO;
import cn.tedu.ivos2.user.service.UserService;
import cn.tedu.ivos2.utils.CacheUtil;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Miyako
 * @Date: 2024-08-30-17:05
 * @Description:
 */
@RestController
@Api(tags = "用户模块")
@RequestMapping("/v1/user")
@Slf4j
public class UserController {
    @Autowired
    UserService userService;


    @PostMapping("login")
    JsonResult login(@RequestBody UserLoginParam userLoginParam){
        log.debug(userLoginParam+"");
        UserVO userVO = userService.login(userLoginParam);
        log.debug("验证通过!");
        return JsonResult.ok(userVO) ;
    }

    /*
     * @param: []
     * @return: code:2000,data:base64位编码的序列化后的验证码图片数据
     * @description:
     **/
    @GetMapping("cap")
    public JsonResult getCaptcha(){
        log.debug("1.开始生成验证码");
        String captcha = userService.getCaptcha();
        return JsonResult.ok(captcha);
    }


}
